package ru.ksu.ktk.diploma.sdi.mapping.resolver.sampling;

import java.util.ArrayList;
import java.util.List;

import ru.ksu.ktk.diploma.sdi.mapping.MappingElement;

/**
 * choose element with maximum weight only
 * 
 * @author coldflame 15.04.2009 20:19:07
 */
public class MaxWeightCommand extends AbstractSamplingCommand{

    public List<MappingElement> execute() {
        List<MappingElement> sampledElements = new ArrayList<MappingElement>();
        List<MappingElement> mappingElements = context.getMappingElements();
        MappingElement chosenElement = null;
        for (MappingElement mappingElement : mappingElements){
            if (chosenElement == null || mappingElement.getWeight() > chosenElement.getWeight()){
                chosenElement = mappingElement;
            }
        }
        sampledElements.add(chosenElement);
        return sampledElements;
    }

}
